package com.ddogring.business.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.ddogring.business.domain.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

/**
 * @BelongsProject: eshop
 * @BelongsPackage: com.ddogring.business.mapper
 * @Author: DdogRing
 * @CreateTime: 2023-01-30  11:18
 * @Description: TODO
 * @Version: 1.0
 */
@Mapper
@Repository
public interface UserMapper extends BaseMapper<User> {

    /**
     * @description: 校验用户名唯一性
     * @author: DdogRing
     * @date: 2023/1/31 09:47
     * @param: [username]
     * @return: int
     **/
    @Select("select count(1) from t_user ${ew.customSqlSegment}")
    int checkUserNameUnique(@Param(Constants.WRAPPER) Wrapper wrapper);

    /**
     * @description: 校验手机号唯一性
     * @author: DdogRing
     * @date: 2023/1/31 09:48
     * @param: [user]
     * @return: int
     **/
    @Select("select count(1) from t_user ${ew.customSqlSegment}")
    int checkPhoneUnique(@Param(Constants.WRAPPER) Wrapper wrapper);

    /**
     * @description: 校验邮箱唯一性
     * @author: DdogRing
     * @date: 2023/1/31 09:51
     * @param: [user]
     * @return: int
     **/
    @Select("select count(1) from t_user ${ew.customSqlSegment}")
    int checkEmailUnique(@Param(Constants.WRAPPER) Wrapper wrapper);

    /**
     * @description: 绑定邮箱
     * @author: DdogRing
     * @date: 2023/1/31 09:57
     * @param: [user]
     * @return: int
     **/
    int bind(User user);
}
